#ifndef _MEMORYZONE_H_
#define _MEMORYZONE_H_

#include "Page.h"
#include "list.h"

// Buddy list NR
#define MAX_ORDER				11

struct free_area {
	list_head<Page> free_list;
	u32 nr_free;
	free_area() { nr_free=0; }
};

class MemoryZone
{
private:
	u32 free_pages;		// Number of free pages in the zone.
	u32 pages_min;		// Number of reserved pages of the zone.
	struct free_area * free_area[MAX_ORDER];	// Buddy System Used
	Page * zone_mem_map;	//Pointer to first page descriptor of the zone.
	u32 zone_start_pfn;	// Index of the first page frame of the zone.
	u32 spanned_pages;	// Total size of zone in pages.
	const char *name;	// Zone name

public:
	MemoryZone(const char * name, u32 zone_start_pfn, u32 spanned_pages, u32 pages_min);
	void Initialize(Page * mem_map);

public:
	Page * RemoveQueue(int order);
	void FreePagesBulk(Page * page, int order);
	bool IsContain(Page *page);
};


#endif

